from django.db import models

from ..build_manage.models import Room, BuildManage

SEX_CHOICES = (
    ('0', '女'),
    ('1', '男')
)


class Houseparent(models.Model):
    id = models.AutoField(db_column='id', primary_key=True)
    username = models.CharField(db_column='username', max_length=30, verbose_name='用户名')
    password = models.CharField(db_column='password', max_length=30, verbose_name='密码')
    name = models.CharField(db_column='name', max_length=20, verbose_name='姓名')
    phone = models.CharField(db_column='phone', blank=True, null=True, max_length=11, verbose_name='手机号')
    sex = models.CharField(max_length=1, choices=SEX_CHOICES, db_column='sex', default='0', verbose_name='性别')
    build_id = models.ForeignKey(BuildManage, models.DO_NOTHING, blank=True, null=True, db_column='build_id',
                                 related_name='houseparent_build_name', verbose_name='楼宇名称')

    class Meta:
        db_table = 'houseparent'
        verbose_name_plural = '宿舍管理员'


class Student(models.Model):
    id = models.AutoField(db_column='id', primary_key=True)
    name = models.CharField(db_column='name', max_length=20, verbose_name='姓名')
    student_number = models.CharField(db_column='student_number', max_length=30, verbose_name='学号')
    phone = models.CharField(db_column='phone', blank=True, null=True, max_length=11, verbose_name='电话')
    sex = models.CharField(max_length=1, choices=SEX_CHOICES, db_column='sex', default='0', verbose_name='性别')

    build_id = models.ForeignKey(BuildManage, models.DO_NOTHING, blank=True, null=True,
                                 related_name='houseparent_build', verbose_name='楼宇名称', db_column='build_id')
    room_id = models.ForeignKey(Room, models.DO_NOTHING, blank=True, null=True, related_name='student_info',
                                verbose_name='寝室号', db_column='room_id', help_text='点击小图标搜索')

    class Meta:
        db_table = 'student'
        verbose_name_plural = '学生'
